from django.db import models
from django.contrib.auth.models import User
from django.urls import reverse
import datetime


class Category(models.Model):
    name = models.CharField(max_length=100)


class Tag(models.Model):
    name = models.CharField(max_length=100)


class Post(models.Model):
    title = models.CharField(max_length=70)
    body = models.TextField()
    created_time = models.DateTimeField(default=datetime.datetime.now())
    modified_time = models.DateTimeField(default=datetime.datetime.now())
    excerpt = models.CharField(max_length=200, blank=True)
    category = models.IntegerField(blank=True)
    tags = models.IntegerField(blank=True)
    author = models.IntegerField(blank=True)

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('blog:detail', kwargs={'pk': self.pk})

    class Meta:
        ordering = ['-created_time']
